package com.goldcn.user.controller;

import com.goldcn.user.service.CountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Created by 1111 on 2016/12/12.
 */
@Api(value = "用户统计管理")
@RestController
@RequestMapping(value = "/count")
public class CountController {
    @Autowired
    CountService countService;


    @ApiOperation(value = "查询内部员工userID的个人及其组织信息type[1只查询用户信息，2包含统计信息]")
    @RequestMapping(value = "/userInfo/{userID}/{type}",method = RequestMethod.GET)
    public Object selectForOrderCount(@PathVariable Long userID, @PathVariable int type)throws Exception{
        return countService.selectForOrderCount(userID,type);
    }
    @ApiOperation(value = "查询员工userID的2销售经理 3销售顾问 4会员 ")
    @RequestMapping(value = "/userInfoStatCount/{userID}/{organizationalID}",method = RequestMethod.GET)
    public Object userInfoStatCount(@PathVariable Long userID, @PathVariable Long organizationalID)throws Exception{
        return countService.selectUserStatCount(userID,organizationalID);
    }


    @ApiOperation(value = "初始化统计会员顾问数量")
    @RequestMapping(value = "/initMember/{companyID}",method = RequestMethod.GET)
    public Object initMember(@PathVariable Long companyID){
        return countService.initMember(companyID);
    }


    @ApiOperation(value = "定时任务每天统计会员顾问数量")
    @RequestMapping(value = "/update",method = RequestMethod.GET)
    public Object updateCount(){
        return countService.updateCount(null,null);
    }

    @ApiOperation(value = "手动传入时间发动定时任务")
    @RequestMapping(value = "/update/{startTime}/{endTime}",method = RequestMethod.GET)
    public Object updateCountManual(@PathVariable Long startTime,@PathVariable Long endTime){
        return countService.updateCount(startTime,endTime);
    }

    @ApiOperation(value = "下属部门或用户的会员数据统计")
    @RequestMapping(value = "/{userID}/{pageNum}/{pageSize}",method = RequestMethod.GET)
    public Object selectCountByDepartment(@PathVariable Long userID, @PathVariable int pageNum,@PathVariable int pageSize)throws Exception{
        return countService.selectCountByDepartment(userID,pageNum,pageSize);
    }

    @ApiOperation(value = "会员数量趋势统计,type[1最近一月 2最近三月 3最近一年]")
    @RequestMapping(value = "/tred/{userID}/{type}",method = RequestMethod.GET)
    public Object getUserQtyTred(@PathVariable Long userID,@PathVariable int type)throws Exception{
        return countService.getUserQtyTred(userID,type);
    }

    @ApiOperation(value = "根据List<oIDOrUserID>,type 来查询对应的name，会员、顾问数；订单统计需求")
    @RequestMapping(value = "/oList/{type}",method = RequestMethod.POST)
    public Object getUserQtyByList(@PathVariable int type, @RequestBody List<Long> list){
        return countService.getUserQtyByList(list,type);
    }

//    @ApiOperation(value = "仅仅查询本部的会员相关统计")
//    @RequestMapping(value = "/selfInfo/{userID}",method = RequestMethod.GET)
//    public Object getSelfInfo(@PathVariable Long userID)throws Exception{
//        return countService.getSelfInfo(userID);
//    }
}
